package org.gcb.core.model;

import java.beans.PropertyChangeListener;
import java.util.Set;
import javax.swing.event.SwingPropertyChangeSupport;

/**
 *
 * @author Jason
 */
public class Toon {
    public static final String PROP_NAME = "name";
    public static final String PROP_LEVEL = "level";
    public static final String PROP_EXPERIENCE = "experience";
    private final AbilitySet abilities;
    private final SkillSet skills;
    private final DefenseSet defenses;
    private final Equipment equipment;
    private Race race;
    private String name;
    private Integer level;
    private Integer experience;
    private Set<MiscModifier<?, ?>> miscModifiers;
    private SwingPropertyChangeSupport propSupport = new SwingPropertyChangeSupport(this, true);

    public Toon(String name) {
        this(name, 1, 1);
    }

    public Toon(String name, Integer level, Integer experience) {
        this.name = name;
        this.level = level;
        this.experience = experience;
        this.abilities = new AbilitySet();
        this.skills = new SkillSet(this);
        this.defenses = new DefenseSet(this);
        this.equipment = new Equipment(this);
        this.equipment.getCarried().getWeight();

    }

    public Set<MiscModifier<?, ?>> getMiscModifiers() {
	return miscModifiers;
    }

    public Equipment getEquipment() {
        return equipment;
    }

    public DefenseSet getDefenses() {
        return defenses;
    }

    public SkillSet getSkills() {
        return skills;
    }

    public AbilitySet getAbilities() {
        return abilities;
    }

    public Integer getExperience() {
        return experience;
    }

    public void setExperience(Integer experience) {
        Integer oldExperience = this.experience;
        this.experience = experience;
        propSupport.firePropertyChange(PROP_EXPERIENCE, oldExperience, this.experience);
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        Integer oldLevel = this.level;
        this.level = level;
        propSupport.firePropertyChange(PROP_LEVEL, oldLevel, this.level);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        String oldName = this.name;
        this.name = name;
        propSupport.firePropertyChange(PROP_NAME, oldName, this.name);
    }

    public void gainLevel() {
        setLevel(this.level+1);
    }

    public void loseLevel() {
        setLevel(this.level-1);
    }

    public void addPropertyChangeListener(PropertyChangeListener pcl) {
        propSupport.addPropertyChangeListener(pcl);
    }
}
